package edu.uafs.museum;

import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

public class Exhibition {
	String id;
	String name;
	String image_url;
	String link;
	String description;
	Bitmap image_bitmap;
	
	/**
	 * The constructor of the class
	 * @param id The id of the exhibition
	 * @param name The name of the exhibition
	 * @param image_url The url to the image
	 * @param link The link to the web page of the exhibition 
	 * @param description The description of the exhibition
	 * @throws IOException If Can't get the image from the URL
	 */
	public Exhibition(String id, String name, String image_url, String link, String description) throws IOException
	{
		this.id = id;
		this.name = name;
		this.image_url = image_url;
		this.link = link;
		this.description = description;
		
		//get the bitmap from the url
		URL url = new URL(image_url);
		HttpURLConnection connection = (HttpURLConnection)url.openConnection();
		connection.setDoInput(true);
		connection.connect();
		InputStream input = connection.getInputStream();
		image_bitmap = BitmapFactory.decodeStream(input);
	}
	
	public Bitmap getImage_bitmap() {
		return image_bitmap;
	}

	public void setImage_bitmap(Bitmap image_bitmap) {
		this.image_bitmap = image_bitmap;
	}

	public void setID(String id)
	{
		this.id = id;
	}
	
	public String getID()
	{
		return id;
	}
	
	public void setName(String name)
	{
		this.name = name;
	}
	
	public String getName()
	{
		return name;
	}

	public String getImage_url() {
		return image_url;
	}

	public void setImage_url(String image_url) {
		this.image_url = image_url;
	}

	public String getLink() {
		return link;
	}

	public void setLink(String link) {
		this.link = link;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
}
